//
//  MyIdentityTableViewController.m
//  FlyGift
//
//  Created by lanou3g on 15/7/16.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//


#import "MyIdentityTableViewController.h"
#import "SexSelectionTableViewController.h"
#import "SelectRoleTableViewController.h"

@interface MyIdentityTableViewController ()

@end

@implementation MyIdentityTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationController.navigationBar.translucent = NO;
    self.navigationItem.title = @"我的身份";
    
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kP6Height(667-64)) style:UITableViewStyleGrouped];
    
    UILabel *line = [[UILabel alloc]initWithFrame:CGRectMake(kP6width(280-250)/2, kP6Height(150), kP6width(20), kP6Height(1))];
    line.backgroundColor = [UIColor blackColor];
    line.alpha = 0.2;
    [self.view addSubview:line];
    
    UILabel *lineOne = [[UILabel alloc]initWithFrame:CGRectMake(kP6width(280-250)/2+250, kP6Height(150), kP6width(20), kP6Height(1))];
    lineOne.backgroundColor = [UIColor blackColor];
    lineOne.alpha = 0.2;
    [self.view addSubview:lineOne];
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(kP6width(280-250), kP6Height(140), kP6width(250), kP6Height(20))];
    label.text = @"小飞飞将根据您的身份推荐最适合的礼物哦~";
    label.alpha = 0.5;
    label.textAlignment = NSTextAlignmentCenter;
    label.font = [UIFont systemFontOfSize:11];
    [self.view addSubview:label];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *dentifier = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:dentifier];
    if (cell == nil)
    {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:dentifier];
    }
    
    //设置选中的cell 点击后没有任何的背景效果
    cell.selectionStyle = UITableViewCellAccessoryNone;
    
    if (indexPath.row == 0)
    {
        UILabel *gender = [[UILabel alloc]initWithFrame:CGRectMake(kP6width(20), kP6Height(5), kP6width(40), kP6Height(40))];
        gender.text = @"性别";
        gender.font = [UIFont systemFontOfSize:14];
        [cell addSubview:gender];
        
        self.boysGirls = [[UILabel alloc]initWithFrame:CGRectMake(kP6width(280-110), kP6Height(5), kP6width(80), kP6Height(34))];
        // 文字右对齐
        _boysGirls.textAlignment = NSTextAlignmentRight;
        self.boysGirls.text = [[NSUserDefaults standardUserDefaults]valueForKey:@"sex"];
        _boysGirls.alpha = 0.5;
        _boysGirls.font = [UIFont systemFontOfSize:14];
        [cell addSubview:_boysGirls];
        
        UIImageView *TheArrowOne = [[UIImageView alloc]initWithFrame:CGRectMake(kP6width(280-20), kP6Height(12), kP6width(10), kP6Height(22))];
        //        myImage.backgroundColor = [UIColor redColor];
        TheArrowOne.image = [UIImage imageNamed:@"右箭头"];
        [cell addSubview:TheArrowOne];
        
    }
    else
    {
        UILabel *role = [[UILabel alloc]initWithFrame:CGRectMake(kP6width(20), kP6Height(5), kP6width(40), kP6Height(40))];
        role.text = @"角色";
        role.font = [UIFont systemFontOfSize:14];
        [cell addSubview:role];
        
        _work = [[UILabel alloc]initWithFrame:CGRectMake(kP6width(280-110), kP6Height(5), kP6width(80), kP6Height(34))];
        //文字右对齐
        _work.textAlignment = NSTextAlignmentRight;
        //        _label1.text = @"资深工作党";
        self.work.text = [[NSUserDefaults standardUserDefaults]valueForKey:@"role"];
        _work.alpha = 0.5;
        _work.font = [UIFont systemFontOfSize:14];
        [cell addSubview:_work];
        
        UIImageView *myImage = [[UIImageView alloc]initWithFrame:CGRectMake(kP6width(280-20), kP6Height(12), kP6width(10), kP6Height(22))];
        //        myImage.backgroundColor = [UIColor redColor];
        myImage.image = [UIImage imageNamed:@"右箭头"];
        [cell addSubview:myImage];
    }
    return cell;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0)
    {
        SexSelectionTableViewController *gender = [[SexSelectionTableViewController alloc]init];
        [self.navigationController pushViewController:gender animated:YES];
    }
    else
    {
        SelectRoleTableViewController *role = [[SelectRoleTableViewController  alloc]init];
        [self.navigationController pushViewController:role animated:YES];
    }
}

//视图将要出现的时候
-(void)viewWillAppear:(BOOL)animated
{
    self.boysGirls.text = [[NSUserDefaults standardUserDefaults]valueForKey:@"sex"];
    self.work.text = [[NSUserDefaults standardUserDefaults]valueForKey:@"role"];
    
}


@end
